﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Reporter.Data;
using ReporterControlLibrary.Models;

namespace Reporter.Controls
{
    /// <summary>
    /// Interaction logic for NewProjectDialogBox.xaml
    /// </summary>
    public partial class NewProjectDialogBox : Window
    {
        public ProjectPreferences ProjectInfo { get; set; }

        public NewProjectDialogBox()
        {
            InitializeComponent();           

            this.Loaded += new RoutedEventHandler(NewProjectDialogBoxLoaded);
            //this.DateFormat_cb.LostFocus +=new RoutedEventHandler(DateFormat_cb_LostFocus);
        }

        void NewProjectDialogBoxLoaded(object sender, RoutedEventArgs e)
        {
            var context = this.FindResource("ProjectInfoDataSource") as ProjectPreferences;
            if (context != null)
            {
                ProjectInfo = context;
            }
        }

        private void OkBtClick(object sender, RoutedEventArgs e)
        {
            // form validation comes here
            this.DialogResult = true;
        }

        private void CancelBtClick(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void DateFormatCbLostFocus(object sender, System.Windows.RoutedEventArgs e)
        {
            //TODO: presun funkcionalitu, aby sa perzistovala na SharePoint ...
            //var comboBox = (ComboBox)sender;
            //var format = comboBox.SelectedItem as string;
            //if (comboBox.Text.Equals(format) || string.IsNullOrEmpty(comboBox.Text))
            //    return;
            //var newItem = comboBox.Text;
            //AppData.DateFormats.Add(newItem);
            //comboBox.SelectedItem = newItem;
        }
    }
}
